package com.maila.calltaxi_driver.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.maila.calltaxi_driver.R;
import com.maila.calltaxi_driver.utils.EventData;
import com.maila.calltaxi_driver.utils.StartActivityUtils;
import com.maila.calltaxi_driver.view.DaulPickerPop;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/7/4.
 */

public class SettingActivity extends AppCompatActivity {
    @BindView(R.id.return_iv)
    AutoRelativeLayout returnIv;
    @BindView(R.id.title_login)
    TextView titleLogin;
    @BindView(R.id.rl_title)
    AutoRelativeLayout rlTitle;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_car_code)
    TextView tvCarCode;
    @BindView(R.id.excepter_certify)
    AutoLinearLayout excepterCertify;
    @BindView(R.id.tv_phone_num)
    TextView tvPhoneNum;
    @BindView(R.id.rl_change_phone_num)
    AutoRelativeLayout rlChangePhoneNum;
    @BindView(R.id.tv_chongzhi_pwd)
    AutoRelativeLayout tvChongzhiPwd;
    @BindView(R.id.tv_work_time)
    TextView tvWorkTime;
    @BindView(R.id.rl_change_time)
    AutoRelativeLayout rlChangeTime;
    @BindView(R.id.rl_my_wallet)
    AutoRelativeLayout rlMyWallet;
    private String worktime="";
    DaulPickerPop timepicker;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setting_activity);
        ButterKnife.bind(this);
        EventBus.getDefault().register(this);
        timepicker = new DaulPickerPop(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onRegisterEvent(EventData data) {
        switch (data.getType()) {
            case EventData.EVENT_TYPE_SELECTE_TIME:
                worktime=data.getObject().toString();
                tvWorkTime.setText(data.getObject().toString());
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @OnClick({R.id.return_iv, R.id.rl_change_phone_num, R.id.tv_chongzhi_pwd, R.id.rl_change_time, R.id.rl_my_wallet})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.return_iv:
                finish();
                break;
            case R.id.rl_change_phone_num:
                StartActivityUtils.start(this,ResetPhoneActivity.class);
                break;
            case R.id.tv_chongzhi_pwd:
                StartActivityUtils.start(this,ForgetPwdActivity.class);
                break;
            case R.id.rl_change_time:
                timepicker.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                break;
            case R.id.rl_my_wallet:
                StartActivityUtils.start(this,WalletActivity.class);
                break;
        }
    }
}
